<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <title>猫小朵</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- jquery -->
    <script src="https://cdn.bootcss.com/jquery/2.2.3/jquery.min.js"></script>
    <!-- 引入layui -->
    <link rel="stylesheet" href="/layui-2.8.17/css/layui.css">
    <script src="/layui-2.8.17/layui.js"></script>
    <!-- 引入bootstrap -->
    <link href="https://cdn.staticfile.org/twitter-bootstrap/5.1.1/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://cdn.bootcss.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/5.1.1/js/bootstrap.bundle.min.js"></script>
    <!-- bootstrap-table.min.js -->
    <script src="https://cdn.bootcss.com/bootstrap-table/1.11.1/bootstrap-table.min.js"></script>
    <!--bootstrap-table 引入中文语言包 -->
    <script src="https://cdn.bootcss.com/bootstrap-table/1.11.1/locale/bootstrap-table-zh-CN.min.js"></script>
</head>
<body>
<div class="container-fluid" style="background-color: gray">
    <!--    <div class="container">-->
    <strong id="repositoryName">仓库名称</strong>
    <div id="userBar" style="float: right">
        <span id="username">未知用户名</span>
        <button id="logout" onclick="logout()">退出</button>
    </div>

    <!--    </div>-->
    <div class="container-fluid row" style="background-color: white">
        <div class="col">
            <span>京东文件密码</span>
            <input type="text" id="jdPassword">
            <br>
            <span>美团文件密码</span>
            <input type="text" id="mtPassword">
            <br>
            <button id="ydExport">生成导入文件</button>
        </div>

        <div class="col">
            <span>日期：</span>
            <input type="text" id="ydSendDate">
            <br>
            <button id="ydSend">生成YD揽收文件</button>
        </div>

        <div class="col">
            <span>日期：</span>
            <input type="text" id="ytgjSendDate">
            <br>
            <button id="ytgjSend">生成YTGJ揽收文件</button>
        </div>
        <div class="col">
            <span>日期：</span>
            <input type="text" id="ytzgSendDate">
            <br>
            <button id="ytzgSend">导入YTZG订单</button>
        </div>
    </div>
    <br>
    <div class="container-fluid row">
        <!--    侧边栏-->
        <div class=" bg-light col-2">
            <ul id="left-nav" class="list-unstyled list-inline col-12" style="margin-top: 50px">
                <li id="goods-li">
                    <a class="btn" onclick=toGoodsPage()>商品管理</a>
                </li>
                <li id="inbound-li">
                    <a class="btn" onclick=toInboundPage()>入库管理</a>
                </li>
                <li id="outbound-li">
                    <a class="btn" onclick=toOutboundPage()>出库管理</a>
                </li>
                <li id="shop-li">
                    <a class="btn" onclick=toShopPage()>店铺管理</a>
                </li>
                <li id="supplier-li">
                    <a class="btn" onclick=toSupplierPage()>供应商管理</a>
                </li>
                <li id="order-li">
                    <a class="btn" onclick=toOrderPage()>订单管理</a>
                </li>
                <li id="count-li">
                    <a id="count-a" class="btn" onclick=toCountPage()>统计报表</a>
                </li>
                <li id="shopGoods-li">
                    <a id="shopGoods-a" class="btn" onclick=toShopGoodsPage()>店铺商品管理</a>
                </li>
            </ul>
        </div>
        <!--    主体-->
        <iframe class="col" id="navFrame" width="100%" height="800px" src="page/goods.html">
        </iframe>

    </div>
</div>

<script>
    $(function ready() {
        $.get({
            url: "/repository/getName",
            success(result) {
                $("title").html(result.data);
                $("#repositoryName").html(result.data);
                $("#username").html(sessionStorage.getItem("username"))
            }
        });

        $("#jdPassword").val("123456")
        $("#mtPassword").val("123456")

        let now = new Date();
        let year = now.getFullYear();
        let month = (now.getMonth() + 1) < 10 ? "0" + (now.getMonth() + 1) : (now.getMonth() + 1);
        let date = now.getDate() < 10 ? "0" + (now.getDate()) : (now.getDate());
        $("#ydSendDate").val(year + "" + month + "" + date);
        $("#ytgjSendDate").val(year + "" + month + "" + date);
        $("#ytzgSendDate").val(year + "" + month + "" + date);

        function layerShow(result) {
            layui.use('layer', function () {
                let layer = layui.layer;
                if (result.success) {
                    layer.msg(result.msg, {icon: 1});
                } else {
                    layer.msg(result.msg, {icon: 2});
                }
            });

        }

        $('#ydExport').click(function () {
            let jdPassword = $("#jdPassword").val()
            let mtPassword = $("#mtPassword").val()
            $.get({
                url: "/yd/writeImportExcel",
                data: {
                    "jdPassword": jdPassword,
                    "mtPassword": mtPassword
                },
                success: function (result) {
                    layerShow(result);
                }
            });
        });
        $('#ydSend').click(function () {
            $.get({
                url: "/yd/writeSendExcel/",
                data: {
                    dateStr: $("#ydSendDate").val()
                },
                success: function (result) {
                    layerShow(result);
                    // alert("订单数量" + result)
                }
            });
        });
        $('#ytgjSend').click(function () {
            $.get({
                url: "/ytgj/writeSendExcel/",
                data: {
                    dateStr: $("#ytgjSendDate").val()
                },
                success: function (result) {
                    layerShow(result);
                    // alert("订单数量" + result)
                }
            });
        });
        $('#ytzgSend').click(function () {
            $.get({
                url: "/ytzg/writeSendExcel/",
                data: {
                    dateStr: $("#ytzgSendDate").val()
                },
                success: function (result) {
                    layerShow(result);
                    // alert("订单数量" + result)
                }
            });
        });

    });

    function logout() {
        $.post({
            url: "/user/logout",
            success(result) {
                location.href = result.data + ".html";
            }
        });
    }

    function toGoodsPage() {
        $("#navFrame").attr("src", "/page/goods.html");
        $("#left-nav li").css("background-color", "white");
        $("#left-nav li a").css("color", "black");
        $("#goods-li").css("background-color", "black");
        $("#goods-li a").css("color", "white");
    }

    function toInboundPage() {
        $("#navFrame").attr("src", "/page/inbound.html");
        $("#left-nav li").css("background-color", "white");
        $("#left-nav li a").css("color", "black");
        $("#inbound-li").css("background-color", "black");
        $("#inbound-li a").css("color", "white");
    }

    function toOutboundPage() {
        $("#navFrame").attr("src", "/page/outbound.html");
        $("#left-nav li").css("background-color", "white");
        $("#left-nav li a").css("color", "black");
        $("#outbound-li").css("background-color", "black");
        $("#outbound-li a").css("color", "white");
    }

    function toShopPage() {
        $("#navFrame").attr("src", "/page/shop.html");
        $("#left-nav li").css("background-color", "white");
        $("#left-nav li a").css("color", "black");
        $("#shop-li").css("background-color", "black");
        $("#shop-li a").css("color", "white");
    }

    function toSupplierPage() {
        $("#navFrame").attr("src", "/page/supplier.html");
        $("#left-nav li").css("background-color", "white");
        $("#left-nav li a").css("color", "black");
        $("#supplier-li").css("background-color", "black");
        $("#supplier-li a").css("color", "white");
    }

    function toOrderPage() {
        $("#navFrame").attr("src", "/page/order.html");
        $("#left-nav li").css("background-color", "white");
        $("#left-nav li a").css("color", "black");
        $("#order-li").css("background-color", "black");
        $("#order-li a").css("color", "white");
    }

    function toCountPage() {
        $("#navFrame").attr("src", "/page/count.html");
        $("#left-nav li").css("background-color", "white");
        $("#left-nav li a").css("color", "black");
        $("#count-li").css("background-color", "black");
        $("#count-li a").css("color", "white");
    }
    function toShopGoodsPage() {
        $("#navFrame").attr("src", "/page/shopGoods.html");
        $("#left-nav li").css("background-color", "white");
        $("#left-nav li a").css("color", "black");
        $("#shopGoods-li").css("background-color", "black");
        $("#shopGoods-a").css("color", "white");
    }

</script>
</body>
</html>